package com.platform;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
//导入可选配置类
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
// 导入对应SMS模块的client
import com.tencentcloudapi.sms.v20210111.SmsClient;
// 导入要请求接口对应的request response类
import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
import com.tencentcloudapi.sms.v20210111.models.SendStatus;

/**
 * Tencent Cloud Sms Sendsms
 *
 */

public class SendSms
{
    public static void main(String [] args) {
        try{
            Credential cred = new Credential("AKIDLWR5SZPzIJ3XliOoxpQjlVyA6k7C1ast", "kDPJwJPDk10i8H9k47uPdZFelb9RR9al");

            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint("sms.tencentcloudapi.com");

            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);

            SmsClient client = new SmsClient(cred, "ap-nanjing", clientProfile);

            SendSmsRequest req = new SendSmsRequest();
            String[] phoneNumberSet1 = {"+8618851050925"};
            req.setPhoneNumberSet(phoneNumberSet1);

            req.setSmsSdkAppId("1400531016");
            req.setTemplateId("987267");
            String[] setTemplateParamSet = {"6666"};
            req.setTemplateParamSet(setTemplateParamSet);
            req.setSignName("笑笑提子采摘园");
            SendSmsResponse resp = client.SendSms(req);
            SendStatus[] sendStatuses = resp.getSendStatusSet();
            boolean flag = true;
            for (SendStatus s : sendStatuses){
                if(!s.getCode().equals("Ok")){
                    flag = false;
                    break;
                }
            }
            System.out.println(SendSmsResponse.toJsonString(resp));
        } catch (TencentCloudSDKException e) {
            System.out.println(e.toString());
        }
    }
}